package string;

import java.util.Arrays;

public class SplitDemo {
    public static void main(String[] args) {
        String str = "abc123def456ghi";
        String[] array = str.split("[0-9]+");
        System.out.println(Arrays.toString(array));

        str = "abc=def=ghi=jkl";
        array = str.split("=");
        System.out.println(Arrays.toString(array));

        //连续出现可拆分项时，之间会拆分出一个空字符串
        str = "abc===def=ghi=jkl";
        array = str.split("=");
        System.out.println(Arrays.toString(array));
        //字符串开始是可拆分项时，最开始会拆分出一个空字符串
        str = "==abc=def=ghi=jkl";
        array = str.split("=");
        System.out.println(Arrays.toString(array));
        //末尾连续拆分出可拆分项时，所有拆分出的空字符串都会被忽略
        str = "abc=def=ghi=jkl================";
        array = str.split("=");
        System.out.println(Arrays.toString(array));
    }
}
